<?php
if(defined("_PARA_CHAT"))
    return;
define("_PARA_CHAT", 1);

require_once "ChatMessage.php";

class Chat extends HTMLable {

    public  $shouts        = null;
    public  $shout_count   = null;
    public  $newest_id     = null;

    function Chat( $shouts ) {

        usort($shouts, "ChatMessage::cmp");

        $this->shouts      = $shouts;
        $this->shout_count = sizeof( $shouts );
        $this->newest_id     = null;
        if($this->shout_count > 0)
            $this->newest_id = $this->shouts[ 0 ]->id;
    }


    function htmlize( $options ) {
        echo "<div id=\"para_chat_shouts\">\n";
        if( $this->shouts == null || !sizeof($this->shouts ) ) {
            echo "<div class=\"para_chat_empty\">",
                "The chat is empty",
                "</div>\n";
        }
        else {
            foreach ( $this->shouts as $shout ) {
                $shout->htmlize( null );
            }
        }
        echo "</div>\n";
    }


}


?>